import scala.io.Source;
import CheckSum.calculate
import java.io.File
import java.io.PrintWriter

object Test {

  def widthOfLength(s: String) = s.length.toString.length
  
  def updateRecordValue(r: Symbol, value: Any) = {
    println(r + value.toString())
    r
  }
  
  def main(args: Array[String]): Unit = {
    
//    val lines = Source.fromFile(args(0)).getLines.toList
//    
////    var maxWidth = 0
////    for (line <- lines)
//    val longestline = lines.reduceLeft((a, b) => if (a.length > b.length) a else b)
//    val maxWidth = widthOfLength(longestline)
//      
//    for (line <- lines) {
//      val numSpaces = maxWidth - widthOfLength(line)
//      val padding = " " * numSpaces
//      println(padding + line.length + " | " + line)
//    }
    
    print(calculate(args(0)))
    
    val sum = new CheckSum
    sum.add(12)
    println(+sum)
    
    val i = -1
    i.toHexString
    
  }
}

object FileMatch {
  private def filesHere = (new java.io.File(".")).listFiles();
  
  private def fileMatch(matcher: String => Boolean) =
    for (file <- filesHere if matcher(file.getName)) yield file
    
  def fileEnding(query:String) = 
    fileMatch(_.endsWith(query))
  
  def fileContain(query: String) = 
    fileMatch(_.contains(query))
    
  def fileRegex(query: String) = 
    fileMatch(_.matches(query))
    
  def writeFile(file: File)(op: PrintWriter => Unit) = {
      val pw = new PrintWriter(file)
      try {
        op(pw)
      } finally {
        pw.close
      }
    }
}
